import { create } from 'zustand' // import zustand library fro
import { subscribeWithSelector } from 'zustand/middleware';
import { immer } from 'zustand/middleware/immer';
const usefishtore = create(immer(subscribeWithSelector((set) => ({
    fish: 1,
    addPopulation: () => {
      set((state) => {state.fish ++ }) // state.fish = state.fish + 1; 
      // set((state) => {state.fish +1}) //这些写法错误！！！  注意
    },

    increasePopulation: () =>{
      set((state) => {
        if(state.fish >1) {
          state.fish --;
        }
      })
    },
   
    removeFish: () => {
      set(state => {state.fish = 0})
    },
  }))));

  export default usefishtore;